package com.hbnu;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;

public class InputStreamReaderDemo01 {
    public static void main(String[] args) {
        String filepath = "E:" + File.separator + "2211.txt";

        File file = new File(filepath);
        try {
            // 读取文件中的内容
            InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(file));
            char[] arr = new char[1024]; // 创建数组，用来保存读取到的字符
            int len = inputStreamReader.read(arr); // 将读取到的字符保存在数组中，并返回长度
            System.out.println(new String(arr, 0, len)); // 输出

        } catch (Exception e) {
            throw new RuntimeException(e);
        }


    }
}
